<template>
  <div class="nav-tab-container">
    <ul class="nav-tab-list">
      <li
        v-for="(tab, index) in tabList"
        :key="index"
        :class="{ active: curTab === index }"
        @click="handleChangeNavTab(index)"
      >
        {{ tab.name }}
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  name: 'multiTab',
  props: {
    curTab: {
      type: Number,
      default: 0
    },
    tabList: {
      type: Array,
      default: () => []
    }
  },
  methods: {
    handleChangeNavTab(index) {
      this.$emit('selectLifeTab', index);
    }
  }
};
</script>

<style lang="scss" scoped>
.nav-tab-container {
  overflow-x: scroll;
  overflow-y: hidden;

  &::-webkit-scrollbar {
    display: none;
  }

  .nav-tab-list {
    height: 0.82rem;
    padding-left: 0.22rem;
    display: flex;

    li {
      height: 100%;
      font-size: 0.28rem;
      padding: 0 0.4rem;
      min-width: 1.92rem;
      box-sizing: border-box;
      font-family: PingFangSC-Regular;
      font-weight: 400;
      color: #333;
      display: flex;
      justify-content: center;
      align-items: center;
      position: relative;

      &.active {
        font-family: PingFangSC-Medium;
        font-weight: 500;
        color: #ff3037;
        background-color: #fff;
        &:after {
          content: '';
          display: block;
          width: 14px;
          height: 2px;
          border-radius: 1px;
          background: #e62525;
          position: absolute;
          bottom: 4px;
          left: 50%;
          margin-left: -7px;
        }
      }
    }
  }
}
</style>
